import React, { PureComponent } from "react";
import { connect } from "react-redux";
import { increment, decrement, reset } from "actions/counter";
import { Button } from "antd";

class Counter extends PureComponent {
  render() {
    return (
      <div>
        <div>当前计数为{this.props.counter.count}</div>
        <Button type="primary" onClick={() => this.props.increment()}>
          自增
        </Button>
        <Button onClick={() => this.props.decrement()}>自减</Button>
        <Button onClick={() => this.props.reset()}>重置</Button>
      </div>
    );
  }
}
export default connect(
  counter => counter,
  dispatch => ({
    increment: () => {
      dispatch(increment());
    },
    decrement: () => {
      dispatch(decrement());
    },
    reset: () => {
      dispatch(reset());
    }
  })
)(Counter);
